import Instance from "@/utils/http.js";
const WAREHOUSE_BASE=`/warehouseInfo/`;

// 分页获取所有仓库
export function useGetAllWarehouseAPI(current:number,pageSize:number){
    return Instance({
        url:WAREHOUSE_BASE+`all`,
        method:'GET',
        params: {current: current, pageSize: pageSize}
    })
}

// 增加仓库
export function useAddWarehouseAPI(warehouse:{}){
    return Instance({
        url:WAREHOUSE_BASE+`saveOne`,
        method:'POST',
        data:warehouse
    })
}

// 删除仓库
export function useDeleteWarehouseAPI(id:number){
    return Instance({
        url:WAREHOUSE_BASE+`${id}`,
        method:'DELETE'
    })
}
// 修改仓库
export function useModifyWarehouseAPI(warehouse:{}){
    return Instance({
        url:WAREHOUSE_BASE+`modifyOne`,
        method:'PUT',
        data:warehouse
    })
}

// 根据Id查询仓库
export function useGetWarehouseByIdAPI(id:number){
    return Instance({
        url:WAREHOUSE_BASE+`${id}`,
        method:'GET'
    })
}

// 根据仓库名称查询仓库
export function useGetWarehouseByNameAPI(name:string){
    return Instance({
        url:WAREHOUSE_BASE+`getAllByName`,
        method:'GET',
        params:{
            name
        }
    })
}

// 根据联系人查询仓库
export function useGetWarehouseByContactAPI(contact:string){
    return Instance({
        url:WAREHOUSE_BASE+`getAllByContact`,
        method:'GET',
        params:{
            contact
        }
    })
}

// 根据地址查询仓库
export function useGetWarehouseByAddressAPI(address:string){
    return Instance({
        url:WAREHOUSE_BASE+`getAllByAddress`,
        method:'GET',
        params:{
            address
        }
    })
}
